/**
 * 
 */
package com.csair.youth.service.impl;

import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.csair.youth.dao.impl.hibernate3.NoticeDaoImpl;
import com.csair.youth.database.Notice;

/**
 * @author mickey
 *
 */
public class NoticeServiceImpl {
	private NoticeDaoImpl dao;

	public NoticeDaoImpl getDao() {
		return dao;
	}

	public void setDao(NoticeDaoImpl dao) {
		this.dao = dao;
	}

	public void saveNotice(Notice item){
		if(item == null) return;
		if(StringUtils.isEmpty(item.getId())) item.setId(null);
		dao.saveOrUpdate(item);
	}
	
	public void deleteNoticeById(String id){
		if(!StringUtils.isEmpty(id)) dao.deleteById(id);
	}
	
	public Notice getNotice(String id){
		return dao.findById(id);
	}
	
	public List<Notice> showLatestNotices(int count){
		return dao.showLatestNotices(count);
	}
}
